
// Vue.prototype.commenPath="http://testvote.wabei.cn"
// var commenPath="http://testvote.wabei.cn"
Vue.prototype.commenPath="http://api.wabei.cn"
commenPath="http://api.wabei.cn"
function setCookie(c_name,value,expiredays){
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
function getCookie(c_name){
if (document.cookie.length>0)
  {
  var c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    var c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
    return ""
}

function getData(cName, isAsync, sCallback, eCallback) {
  var url = Vue.prototype.commenPath + cName;
  $.ajax({
      async: isAsync,
      url: url,
      dataType: "json",
      type: 'GET',
      success: function (res) {
          sCallback(res);
      },
      error: function (a, b, c) {
          eCallback(a, b, c);
      }
  });
}

function getData2(cName, isAsync, sCallback, eCallback) {
    var url = scName;
    $.ajax({
        async: isAsync,
        url: url,
        dataType: "json",
        type: 'GET',
        success: function (res) {
            sCallback(res);
        },
        error: function (a, b, c) {
            eCallback(a, b, c);
        }
    });
  }
function postData(cName, pData, sCallback, eCallback) {
  var url = Vue.prototype.commenPath + cName;
  $.ajax({
      url: url,
      dataType: "json",
      type: "POST",
      data: pData,
      success: function (res) {
          sCallback(res);
      },
      error: function (a, b, c) {
          eCallback(a, b, c);
      }
  });
}
function postData2(cName, pData, sCallback, eCallback) {
    var url = cName;
    $.ajax({
        url: url,
        dataType: "json",
        type: "POST",
        data: pData,
        success: function (res) {
            sCallback(res);
        },
        error: function (a, b, c) {
            eCallback(a, b, c);
        }
    });
  }
function WxShare(obj) {
    this.config = function () {
        wx.config({
            debug: false,
            appId: obj.appId,
            timestamp: obj.timestamp,
            nonceStr: obj.nonceStr,
            signature: obj.signature,
            jsApiList: ["onMenuShareAppMessage",
                "onMenuShareTimeline",
                "onMenuShareQQ",
                "onMenuShareWeibo",
                "hideOptionMenu",
                "showOptionMenu",
                "hideMenuItems",
                "showMenuItems",
                "hideAllNonBaseMenuItem",
                "showAllNonBaseMenuItem"]
        });
        wx.ready(function () {
            wx.onMenuShareTimeline({
                title: obj.share_title,
                link: obj.share_url,
                imgUrl: obj.share_imgurl,
                desc: obj.share_desc,
                success: function () {
                }, cancel: function () {
                }
            }); wx.onMenuShareAppMessage({
                title: obj.share_title,
                link: obj.share_url,
                imgUrl: obj.share_imgurl,
                desc: obj.share_desc,
                type: "",
                dataUrl: "",
                success: function () {
                }, cancel: function () {
                }
            }); wx.onMenuShareQQ({
                title: obj.share_title,
                link: obj.share_url,
                imgUrl: obj.share_imgurl,
                desc: obj.share_desc,
                success: function () { },
                cancel: function () { }
            }); wx.onMenuShareWeibo({
                title: obj.share_title,
                link: obj.share_url,
                imgUrl: obj.share_imgurl,
                desc: obj.share_desc,
                success: function () { },
                cancel: function () { }
            }); wx.onMenuShareQZone({
                title: obj.share_title,
                link: obj.share_url,
                imgUrl: obj.share_imgurl,
                desc: obj.share_desc,
                success: function () { },
                cancel: function () { }
            });
        });
    };
}
WxShare.prototype.init = function () {
    this.config();
};
  //获取url参数的值
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}